﻿using System;
using NUnit.Framework;

namespace RESTController
{
    [TestFixture]
    public class PagedListTests
    {
        [Test]
        public void Constructor_WhenPageSizeLessThan0_ThrowsException()
        {
            var collection = new[] { 1, 2, 3, 4 };
            Assert.Throws<ArgumentException>(() => new PagedList<int>(collection, 0, -1));
        }

        [Test]
        public void TotalCount_EqualsCollectionCount()
        {
            var collection = new[] { 1, 2, 3, 4 };
            var pagedList = new PagedList<int>(collection, 0, 5);
            Assert.AreEqual(4, pagedList.TotalCount);
        }

        [Test]
        public void TotalPages_WhenCountIs0_Returns1()
        {
            var collection = new int[] { };
            var pagedList = new PagedList<int>(collection, 0, 5);
            Assert.AreEqual(1, pagedList.TotalPages);
        }

        [Test]
        public void TotalPages_WhenCountIsLessThanPageSize_Returns1()
        {
            var collection = new int[] { 1, 2, 3, 4 };
            var pagedList = new PagedList<int>(collection, 0, 5);
            Assert.AreEqual(1, pagedList.TotalPages);
        }
    }
}
